package eos.dom.server;

import java.util.Stack;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class CardStack{
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	@Persistent
	private CardId id;
	@Persistent
	private Integer size;

	public CardStack(CardId id) {
		if(new Card(id).isVictory()){
			size = 12;
		}else if(id == CardId.COPPER||id == CardId.SILVER||id == CardId.GOLD || id == CardId.POTION){
			size = 40;
		}else if(id == CardId.CURSE){
			size = 30;
		}else{
			size = 10;
		}
		this.id = id;
	}
	
	public CardId getId(){
		return id;
	}

	public boolean isEmpty() {
		return size == 0;
	}

	public Card pop() {
		size--;
		return new Card(id);
	}

	public int size() {
		return size;
	}
	
	@Override
	public String toString() {
		return "["+id+"]";
	}

}
